/*
 * Copyright (c) 2009-2013 EvTech Project
 * All rights reserved.
 * 
 * This file is part of Game packet.
 *
 * Game packet is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Game packet is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Game packet.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package fi.honkalampisaatio.game.game;

import java.util.Enumeration;
import java.util.Hashtable;

public class LanguageResource {
	public static LanguageResource INSTANCE;
	private Hashtable<String, String> dic;
	
	public static LanguageResource getInstance() {
		if(INSTANCE==null) {
			INSTANCE = new LanguageResource();
		}
		return INSTANCE;
	}
	
	public LanguageResource() {
		dic = new Hashtable<String, String>();
		dic.put("ROUNDS10", "10 rounds");
		dic.put("ROUNDS20", "20 rounds");
		dic.put("ROUNDS30", "30 rounds");
		dic.put("EASY", "Easy");
		dic.put("NORMAL", "Normal");
		dic.put("HARD", "Hard");
		
		dic.put("NONE", "No");
		
		dic.put("TRUE", "Yes");
		dic.put("FALSE", "No");

		dic.put("NO", "No");
		dic.put("SLOW", "Slow");
		dic.put("FAST", "Fast");
		dic.put("VERY_FAST", "Very fast");

		dic.put("DIFFICULTYLABEL_TEXT", "Difficulty");
		dic.put("SHOWTIMELABEL_TEXT", "Show time");
		dic.put("OMITMISTAKESLABEL_TEXT", "Omit mistakes");
		dic.put("SHOWSCORELABEL_TEXT", "Show score");
		dic.put("SHOWTIMEMETERLABEL_TEXT", "Show time meter");
		dic.put("BUTTONLABEL_TEXT", "Used buttons");
		dic.put("USEONLYCOLORSFORCHOICEBUTTONSLABEL_TEXT", "Use only colors for choice buttons");
		dic.put("CHOOSECORRECTANSWERIMAGEBUTTON_TEXT", "Choose correct answer image");

		dic.put("OKBUTTON_TEXT", "Ok");
		dic.put("CANCELBUTTON_TEXT", "Back");
		
		dic.put("GAMEOVER_TIMEOUT_TEXT", "Time out, game over");
		dic.put("GAMEOVER_ALLROUNDSPLAYED_TEXT", "All rounds played, game over");
		dic.put("GAME_END_TEXT", "Game over");
		dic.put("NEWROUND_TEXT", "New round");

		dic.put("HIGHSCORETITLE_TEXT", "Highscore");

		dic.put("TIMEFORMAT", "m'min' ss'sec'");
		dic.put("TIME", "Time");
		dic.put("SCORES", "Score");
		dic.put("HIGHSCORE_NEW_TEXT", "NEW!");
		dic.put("PRESS_ANY_BUTTON_TEXT", "Press any button to continue");
	}

	public void setValue(String key, String value)
	{
		if(key==null || value==null)
			return;
		dic.put(key, value);
	}
	
	public String get(String key) {
		return dic.get(key);
	}
	
	public String getKey(String value) {
		Enumeration<String> keyList = dic.keys();
		while(keyList.hasMoreElements()) {
			String key = keyList.nextElement();
			if(dic.get(key).equalsIgnoreCase(value)) {
				return key;
			}
		}
		return null;
	}
}
